<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div{
            border: 1px solid #000;
        }
        #mainDiv{
            width: 200px;
        }
        .head{
            background-color: aqua;
            text-align: center;
            height: 30px;
            cursor: pointer;
        }
        .body{
            background-color: yellow;
            text-align: center;
            height: 100px;
            display: none;
        }
    </style>

    <script>
        function showDiv(divId){
            //根据ID得到对象
            var divObj = document.getElementById(divId);
            if(divObj.style.display == "block"){
                divObj.style.display = "none";
            }
            else{
                divObj.style.display  = "block";
            }
        }
    </script>
</head>
<body>
    <div id="mainDiv">
        <div class="head" onclick="showDiv('friendDiv')">好友</div>
        <div class="body" id="friendDiv">
            韦小宝<br>
            陈近南<br>
            风际中
        </div>
        <div class="head" onclick="showDiv('parentDiv')">亲人</div>
        <div class="body" id="parentDiv">
            段誉<br>
            虚竹<br>
            乔峰
        </div>
        <div class="head" onclick="showDiv('backDiv')">黑名单</div>
        <div class="body" id="backDiv">
            海大富<br>
            岳不群<br>
            东方不败
        </div>
    </div>
</body>
</html>